﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NGUYENTHUTRANG
{
    public partial class calculator : Form
    {
        public calculator()
        {
            InitializeComponent();
        }
        string chuoidau = "0", chuoihai = "0", s;
        int dau = 0;
        private void calculator_Load(object sender, EventArgs e)
        {

        }

        private void btnbackspace_Click(object sender, EventArgs e)
        {
            if(txtketqua.Text=="")
            {
                MessageBox.Show("Bạn chưa nhập số để tính :D");
            }
            else
            {
                s = txtketqua.Text;
                 s.Substring(0, s.Length - 1);
                txtketqua.SelectionStart = s.Length;
                if(dau==0)
                {
                    chuoidau = txtketqua.Text;
                    chuoidau.Substring(0, chuoidau.Length - 1);
                    txtketqua.SelectionStart = chuoidau.Length;
                    chuoidau = txtketqua.Text;    
                }
                else
                {

                    txtketqua.Text = chuoihai.Substring(0, chuoidau.Length - 1);
                    txtketqua.SelectionStart = chuoihai.Length;
                    chuoihai = txtketqua.Text;
                }
            }
        }
    }
}
